//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.facebook.ads;
import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;

import com.cs.bd.ad.manager.AdSdkManager;
import com.cs.bd.ad.self.WapsAdsSdkHelper;
import com.play.screen.livescreen.AdInfo;
import java.util.List;

public class NativeAd implements Ad {

    private AdInfo mAdInfo;

    private Context context;

    private OnClickListener mOnClickListener;

    private AdSdkManager.ILoadAdvertDataListener mLoadAdvertDataListener;

    public NativeAd(Context context, AdSdkManager.ILoadAdvertDataListener mLoadAdvertDataListener) {
        this.context = context;
        this.mLoadAdvertDataListener = mLoadAdvertDataListener;
    }

    public void loadAd() {
        mAdInfo = WapsAdsSdkHelper.getAdInfo(context);
    }

    public void destroy() {
    }

    public AdInfo getAdInfo() {
        return mAdInfo;
    }

    public String getPlacementId() {
        return null;
    }

    public boolean isAdLoaded() {
        return mAdInfo != null;
    }

    public Bitmap getIcon() {
        return mAdInfo.getAdIcon();
    }

    public NativeAd.Image getAdIcon() {
        try {
            return new Image(mAdInfo.getImageUrls()[1], 300, 500);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Image(mAdInfo.getImageUrl(), 300, 500);
    }

    public NativeAd.Image getAdCoverImage() {
        return new Image(TextUtils.isEmpty(mAdInfo.getImageUrl()) ? mAdInfo.getImageUrls()[0] : mAdInfo.getImageUrl(), 300, 560);
    }

    public String getAdTitle() {
        return !isAdLoaded() ? null : mAdInfo.getAdName();
    }

    public String getAdSubtitle() {
        return !isAdLoaded() ? null : mAdInfo.getAdText();
    }

    public String getAdBody() {
        return !isAdLoaded() ? null : mAdInfo.getDescription();
    }

    public String getAdCallToAction() {
        return !isAdLoaded() ? null : "查看";
    }

    public String getAdSocialContext() {
        return !isAdLoaded() ? null : null;
    }

    @Deprecated
    public NativeAd.Rating getAdStarRating() {
        return !isAdLoaded() ? null : new Rating(5, 5);
    }

    public String getId() {
        return !isAdLoaded() ? null : mAdInfo.getAdId();
    }

    public NativeAd.Image getAdChoicesIcon() {
        return !isAdLoaded() ? null : null;
    }

    public String getAdChoicesLinkUrl() {
        return !isAdLoaded() ? null : null;
    }

    public void registerViewForInteraction(final View var1) {
        var1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                WapsAdsSdkHelper.downloadAd(context, getId());
                if (null != mOnClickListener) {
                    mOnClickListener.onClick(v);
                }
                if (null != mLoadAdvertDataListener) {
                    mLoadAdvertDataListener.onAdClicked(v);
                }
            }
        });
    }

    public void setOnClickListener(OnClickListener mOnClickListener) {
        this.mOnClickListener = mOnClickListener;
    }

    public void registerViewForInteraction(View var1, List<View> var2) {

    }

    public void unregisterView() {
    }

    public static class Rating {
        private final double a;
        private final double b;

        public Rating(double var1, double var3) {
            a = var1;
            b = var3;
        }

        public double getValue() {
            return a;
        }

        public double getScale() {
            return b;
        }
    }

    public static class Image {
        private final String a;
        private final int b;
        private final int c;

        public Image(String var1, int var2, int var3) {
            a = var1;
            b = var2;
            c = var3;
        }

        public String getUrl() {
            return a;
        }

        public int getWidth() {
            return b;
        }

        public int getHeight() {
            return c;
        }
    }
}
